package com.lagou.rpc.codec;

import com.alibaba.fastjson.JSON;

/**
 * @ClassName JSONSerializer
 * @Description 采用JSON的方式，定义JSONSerializer的实现类
 * @Author wugz
 * @Date 2020/4/19 20:30
 * @Version 1.0
 */
public class JSONSerializer implements Serializer {



    @Override
    public byte[] serialize(Object object) {
        return JSON.toJSONBytes(object);
    }



    @Override
    public <T> T deserialize(Class<T> clazz, byte[] bytes) {
        return JSON.parseObject(bytes, clazz);
    }
}
